const { defineConfig } = require("@vue/cli-service");
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');

module.exports = defineConfig({
  transpileDependencies: true,
  publicPath: process.env.NODE_ENV === "production" ? "./" : "/",
  outputDir: "dist",
  chainWebpack: (config) => {
    config.plugin("html").tap((args) => {
      args[0].title = "健康告知单";
      return args;
    });
  },
  configureWebpack: {
    plugins: [
      new NodePolyfillPlugin() // 添加 NodePolyfillPlugin
    ],
    resolve: {
      fallback: {
        "https": require.resolve("https-browserify"),
        "http": require.resolve("stream-http"),
        "stream": require.resolve("stream-browserify"),
        "buffer": require.resolve("buffer/"),
        "url": require.resolve("url/"),
        "crypto": require.resolve("crypto-browserify"),
        // 添加其他需要的 polyfills
      }
    }
  },
  // devServer: {
  //   proxy: {
  //     '/api': { 
  //       target: 'http://10.9.139.14:8081', 
  //       changeOrigin: true, 
  //       pathRewrite: { 
  //         '^/api': ''
  //       }
  //     }
  //   }
  // }
  // devServer: {
  //   proxy: {
  //     '/api': {
  //       target: 'http://10.9.139.14:8081',// 后端接口
  //       changeOrigin: true, // 是否跨域
  //       pathRewrite: {
  //         '/api': ''
  //       }
  //     }
  //   }
  // }
});
